<!-- 单视频播放 Pop 组件 -->
<template>
  <div v-if="status" class="back_mask">
    <div :class="resolving !== 1920 ? 'prop' : 'prop1920'">
      <!-- // 如果左边是 video 右边就是 img -->
      <video class="video" :src="data.content.left.src" autoplay loop />

      <img
        :class="resolving !== 1920 ? 'img' : 'img1920'"
        :src="data.content.right[currentPage].src"
      />
      <template
        v-for="(item, index) in resolving !== 1920
          ? data.content.right[currentPage].position
          : data.content.right[currentPage].positiontow"
      >
        <img
          :key="index"
          class="click_btn"
          :src="item.btn_src"
          :style="getStyle(item)"
          @click="getAction(item.action)"
        />
      </template>

      <div class="close" @click="close()" />
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';

export default {
  components: {},
  // import引入的组件需要注入到对象中才能使用
  props: {
    data: Object,
    status: {
      type: Boolean,
      default: false
    }
  },
  data() {
    // 这里存放数据
    return {
      currentPage: 0,
      resolving: ""
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    if (window.screen.width <= 1920 && window.screen.width > 1366) {
      this.resolving = 1920;
    } else if (window.screen.width > 1920) {
      this.resolving = 1920;
    }
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  // 方法集合
  methods: {
    close() {
      this.currentPage = 0;
      this.$emit("close-pop", null);
      //显示左上后退和右上回家按钮
      this.$store.commit("setHomeBack", true);
      this.$store.commit("setSelectTagImg", true);
      this.$store.commit("setImgListStatus", true);
    },
    getAction(item) {
      switch (item) {
        case "next":
          this.currentPage++;
          break;
        case "pre":
          this.currentPage--;
          break;
        case "start":
          this.currentPage = 0;
          break;
      }
    },
    getStyle(item) {
      let topRate;
      if (window.screen.height <= 1050) {
        // 1050
        topRate = 115;
      } else if (window.screen.height <= 1080) {
        // 1080
        topRate = 122;
      } else {
        topRate = 120;
      }
      return {
        left: (item.left / 1920) * 100.3 + "%",
        top: (item.top / 1080) * topRate + "%",
        width: (item.width / 1080) * 100 + "vw",
        height: (item.height / 1080) * 100 + "vw"
      };
    }
  } // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类

.back_mask {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: rgba(0, 0, 0, 0.7);
  .prop {
    .video {
      position: absolute;
      width: 100%;
      height: 100%;
      object-fit: fill;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    .img {
      position: absolute;
      top: 23%;
      right: 5%;
      height: 49vh;
      width: 33vw;
      border-radius: 15px;
      display: block;
    }
    .close {
      width: 4%;
      height: 7%;
      background: url("https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/关于华为云/exibihition/Hall/ui/close.png");
      background-size: 100% 100%;
      position: absolute;
      right: -2%;
      top: -3%;
      z-index: 100;
    }
  }
  .prop1920 {
    .video {
      position: absolute;
      width: 100%;
      height: 100%;
      object-fit: fill;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    .img {
      position: absolute;
      top: 23%;
      right: 5%;
      height: 49vh;
      width: 33vw;
      border-radius: 15px;
      display: block;
    }
    .img1920 {
      position: absolute;
      top: 23%;
      right: 4.9%;
      height: 54vh;
      width: 35.5vw;
      border-radius: 15px;
      display: block;
    }
    .close {
      width: 4%;
      height: 7%;
      background: url("https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/关于华为云/exibihition/Hall/ui/close.png");
      background-size: 100% 100%;
      position: absolute;
      right: -2%;
      top: -3%;
      z-index: 100;
    }
    position: absolute;
    width: 80.2vw;
    height: 93vh;
    background-color: white;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .click_btn {
    cursor: pointer;
    position: absolute;
    z-index: 1;
  }
  .click_btn:hover {
    transform: scale(1.1, 1.1);
  }
  .close:hover {
    transform: scale(1.1, 1.1);
  }
}
@media screen and (max-width: 1680) {
  .back_mask .close {
    top: 70px;
  }
}
</style>
